/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qsdm.es.persistence;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alberto
 */
@Entity
@Table(name = "curso", catalog = "qsdm", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Curso.findAll", query = "SELECT c FROM Curso c"),
    @NamedQuery(name = "Curso.findById", query = "SELECT c FROM Curso c WHERE c.id = :id"),
    @NamedQuery(name = "Curso.findByCodigo", query = "SELECT c FROM Curso c WHERE c.codigo = :codigo"),
    @NamedQuery(name = "Curso.findByNombre", query = "SELECT c FROM Curso c WHERE c.nombre = :nombre"),
    @NamedQuery(name = "Curso.findByHorasSemanales", query = "SELECT c FROM Curso c WHERE c.horasSemanales = :horasSemanales"),
    @NamedQuery(name = "Curso.findByAnios", query = "SELECT c FROM Curso c WHERE c.anios = :anios"),
    @NamedQuery(name = "Curso.findByTipoFormacion", query = "SELECT c FROM Curso c WHERE c.tipoFormacion = :tipoFormacion"),
    @NamedQuery(name = "Curso.findByCoste", query = "SELECT c FROM Curso c WHERE c.coste = :coste")})
public class Curso implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "codigo", length = 45)
    private String codigo;
    @Column(name = "nombre", length = 45)
    private String nombre;
    @Column(name = "horasSemanales")
    private Integer horasSemanales;
    @Column(name = "anios")
    private Integer anios;
    @Column(name = "tipoFormacion", length = 45)
    private String tipoFormacion;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "coste", precision = 22)
    private Double coste;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "curso", fetch = FetchType.LAZY)
    private List<Calendariocurso> calendariocursoList;
    @JoinColumn(name = "centroFormacion", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Centroformacion centroFormacion;
    @JoinColumn(name = "formacion", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Formacion formacion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "curso1", fetch = FetchType.LAZY)
    private List<Horariocurso> horariocursoList;

    public Curso() {
    }

    public Curso(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Integer getHorasSemanales() {
        return horasSemanales;
    }

    public void setHorasSemanales(Integer horasSemanales) {
        this.horasSemanales = horasSemanales;
    }

    public Integer getAnios() {
        return anios;
    }

    public void setAnios(Integer anios) {
        this.anios = anios;
    }

    public String getTipoFormacion() {
        return tipoFormacion;
    }

    public void setTipoFormacion(String tipoFormacion) {
        this.tipoFormacion = tipoFormacion;
    }

    public Double getCoste() {
        return coste;
    }

    public void setCoste(Double coste) {
        this.coste = coste;
    }

    @XmlTransient
    public List<Calendariocurso> getCalendariocursoList() {
        return calendariocursoList;
    }

    public void setCalendariocursoList(List<Calendariocurso> calendariocursoList) {
        this.calendariocursoList = calendariocursoList;
    }

    public Centroformacion getCentroFormacion() {
        return centroFormacion;
    }

    public void setCentroFormacion(Centroformacion centroFormacion) {
        this.centroFormacion = centroFormacion;
    }

    public Formacion getFormacion() {
        return formacion;
    }

    public void setFormacion(Formacion formacion) {
        this.formacion = formacion;
    }

    @XmlTransient
    public List<Horariocurso> getHorariocursoList() {
        return horariocursoList;
    }

    public void setHorariocursoList(List<Horariocurso> horariocursoList) {
        this.horariocursoList = horariocursoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Curso)) {
            return false;
        }
        Curso other = (Curso) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qsdm.es.persistence.Curso[ id=" + id + " ]";
    }
    
}
